[#ftl]
	
 [@define "agile.form.DateTextBox" "agile.form.DateTimeTextBoxMixin"]
	category:"DateTextBox Component"
	,widgetName:"DateTextBox"
	,attributes:agile.delegate(agile.form.DateTimeTextBoxMixin.prototype.attributes,{
		value: lang.mixin({},agile.DateMetadata,{label:"i18n_value"})					
		,"constraints.min":lang.mixin({},agile.DateMetadata,{
				label:"i18n_min_value"
				,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){
					if(!value){
						value = agile.DateMetadata.MINIMUM;
						widget.metadata(this.metadataCategory+"."+name,null);
					}else{
						widget.metadata(this.metadataCategory+"."+name,value);
					}
					widget.delegate.constraints.min = value;
				}
		})
		,"constraints.max":lang.mixin({},agile.DateMetadata,{
				label:"i18n_max_value"
				,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){
					if(!value){
						value = agile.DateMetadata.MAXIMUM;
						widget.metadata(this.metadataCategory+"."+name,null);
					}
					else{
						widget.metadata(this.metadataCategory+"."+name,value);
					}
					widget.delegate.constraints.max = value;
					
					//console.log("#####constraints.max:",widget.metadata("parameters.constraints_max"));
				}		
		})
		,"constraints.selector":{
			options:agile.i18nMap(["date","datetime"],null,true)
		}
		,"constraints.formatLength":lang.mixin({},agile.ComboMetadata, {
				label:"i18n_format_length"
				,options:agile.i18nMap(["short","medium","long","full"],null,true)
				,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){					
					if(!value){
						value = null;
					}
					var dateValue = widget.delegate.get("value");										
					widget.delegate.constraints.formatLength = value;					
					widget.delegate.reset1("value",dateValue);
					widget.metadata(this.metadataCategory+"."+name,value);
				}
		})
		,"constraints.datePattern": lang.mixin({},agile.ComboMetadata, {
				label:"i18n_date_pattern"
				,options:agile.i18nMap(["yyyy-MM-dd","yyyy-MMM-dd","dd-MM-yyyy","dd-MMM-yyyy"],null,true)
				,onValueChange:function(/*widget*/widget,/*String*/name,/*Object*/value){
					if(!value){
						value = null;
					}
					var dateValue = widget.delegate.get("value");
					widget.delegate.constraints.datePattern = value;		
					widget.delegate.reset1("value",dateValue);
					widget.metadata(this.metadataCategory+"."+name,value);
				}
		   })
	})	
	,_getDelegatePrototype:function(){
 		agile.requireX("dijit/form/DateTextBox");
		return dijit.form.DateTextBox.prototype;
	}
	,initDefaultMetadata:function(){		
		this.metadata("parameters.value",null);
		//this.metadata("parameters.value",new Date());
		//this.metadata("parameters.constraints",{});			
	}
//	,init:function(){
//		aspect.before(this,"metadata",lang.hitch(this,function(){
//			if(arguments[0].indexOf("constraints") != -1){
//				if(arguments.length == 2){					
//					 if(arguments[1] != undefined){
//						console.log("####",arguments);
//					}else{
//						console.error("####",arguments);
//					}
//				}
//			}
//		}),true);
//		
//		aspect.after(this,"metadata",lang.hitch(this,function(name,value){
//			if(arguments[0].indexOf("constraints") != -1){
//				if(arguments.length == 2){					
//					 if(arguments[1] != undefined){
//						console.log("$$$$",arguments);
//					}else{
//						console.error("$$$$",arguments);
//					}
//				}
//			}
//		}),true);
//	}
[/@]
